<?php
// http://localhost/admin/ajax/check-login/name/ad
require_once('Zend/Controller/Action.php');

class Admin_AjaxController extends Zend_Controller_Action
{
    public function checkLoginAction() {

        if ($this->getRequest()->isXmlHttpRequest()) {

            $login = $this->_getParam('login');

            if ($login != '') {
                $table_user = new Core_Model_Table_User();
                $where = $table_user->select()->where('user_login = ?', $login);
                $data = $table_user->fetchRow($where);
                if ($data != NULL) {
                    $result = 'exist !';
                } else {
                    $result = 'not exist !';
                }
            } else {
                $result = 'should not be empty !';
            }
            
            $this->view->result = $result;

        } else {
            exit('it is not XmlHttpRequest');
        }

    }

}